# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=crabstick
pkgver=47.bb7827f
pkgrel=9
pkgdesc='Automatic remote/local file inclusion vulnerability analysis and exploit tool.'
arch=('any')
groups=('blackarch' 'blackarch-webapp' 'blackarch-exploitation')
url='https://github.com/Hack-Hut/CrabStick'
license=('custom:unknown')
depends=('python' 'python-paramiko' 'python-urllib3' 'python-requests'
         'python-docopt' 'python-beautifulsoup4')
makedepends=('git')
source=("$pkgname::git+https://github.com/Hack-Hut/CrabStick.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  cd $pkgname

  mv "${pkgname}s.py" "$pkgname.py"
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  cp -a --no-preserve=ownership * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python $pkgname.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

